;
(function () {

  'use strict';

  angular.module('directives.customActivity')
    .directive('summaryUpaySuccessRateLayout', summaryUpaySuccessRateLayout)
    .directive('summaryUpaySuccessRate', summaryUpaySuccessRate)
    .directive('summaryProvinceBusSuccessRate', summaryProvinceBusSuccessRate)
    .directive('summaryProvinceBusSuccessRateLayout', summaryProvinceBusSuccessRateLayout)
    .directive('summaryProvinceSysSuccessRate', summaryProvinceSysSuccessRate)
    .directive('summaryProvinceSysSuccessRateLayout', summaryProvinceSysSuccessRateLayout)
    .directive('summaryTotalBusSuccessRate', summaryTotalBusSuccessRate)
    .directive('summaryTotalBusSuccessRateLayout', summaryTotalBusSuccessRateLayout)
    .directive('summaryTotalSysSuccessRate', summaryTotalSysSuccessRate)
    .directive('summaryTotalSysSuccessRateLayout', summaryTotalSysSuccessRateLayout)
    .directive('summaryProvinceTotalBusSuccessRateLayout', summaryProvinceTotalBusSuccessRateLayout);

  function summaryUpaySuccessRateLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-upay-success-rate-layout">' +
      '<label class="title title-color2">统一支付</label>' +
      '<div slider slider-include="summary-upay-success-rate"></div>' +
      '</div>'
    }
  }

  function summaryUpaySuccessRate(summaryUpaySuccessRateService) {

    return {
      restrict: 'A',
      template: '<aquarius width="100" height="100" percentage="successRate[type]" text="successRate[type]"' +
      'scolor="scolor" fontcolor="successRate[type+\'Color\']" style="border: 5px solid #DCDBDB;border-radius: 100px;"></aquarius>' +
      '<div ng-if=\"type===\'SYS\'\">系统处理成功率</div>' +
      '<div ng-if=\"type===\'BUS\'\">业务处理成功率</div>' +
      '<core-loading ng-hide="successRate.loading"></core-loading>',
      scope: true,
      link: function (scope, element, attrs) {
        scope.scolor = '#2196F3';
        scope.successRate = summaryUpaySuccessRateService;
        scope.type = attrs.summaryUpaySuccessRate;
        summaryUpaySuccessRateService.init(attrs.summaryUpaySuccessRate);
      }
    }
  }

  summaryUpaySuccessRate.$inject = ['summaryUpaySuccessRateService']

  function summaryProvinceTotalBusSuccessRateLayout(summaryProvinceTotalBusSuccessRateService) {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="2" draggable="true" class="model" ' +
      'module-name="summary-province-total-bus-success-rate-layout">' +
      '<label class="title title-color2">分省全业务流程业务处理成功率</label>' +
      '<div class="center">' +
      '<table class="maptable">' +
      '<tr>' +
      '<td><span></span>最高</td>' +
      '<td ng-repeat="t in successRate.max track by $index">' +
      '<div ng-if="t">{{t.name}}' +
      '<span>{{t.value | currency:\'\'}}%</span>' +
      '</div>' +
      '<div ng-if="!t">--</div>' +
      '</td>' +
      '</tr>' +
      '<tr>' +
      '<td><span></span>最低</td>' +
      '<td ng-repeat="t in successRate.min track by $index">' +
      '<div ng-if="t">{{t.name}}<span>{{t.value | currency:\'\'}}%</span></div>' +
      '<div ng-if="!t">--</div></td>' +
      '</tr></table><div class="body-map"></div></div>' +
      '<core-loading ng-hide="successRate.loading"></core-loading></div>',
      link: function (scope, element) {
        scope.successRate = summaryProvinceTotalBusSuccessRateService;
        summaryProvinceTotalBusSuccessRateService.init(element.find('div')[1]);
      }
    }
  }

  summaryProvinceTotalBusSuccessRateLayout.$inject = ['summaryProvinceTotalBusSuccessRateService'];

  var temp = '<aquarius width="100" height="100" percentage="successRate[sys]" text="successRate[sys]"' +
    'scolor="scolor" fontcolor="successRate[sys+\'Color\']" style="border: 5px solid #DCDBDB;border-radius: 100px;"></aquarius>' +
    '<div ng-if="sys===\'UPAY\'"></div>' +
    '<div ng-if="sys!==\'UPAY\'">{{sys | busLineFilter}}</div>' +
    '<core-loading ng-hide="successRate.loading"></core-loading>';

  function summaryTotalSysSuccessRateLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-total-sys-success-rate-layout">' +
      '<label class="title title-color2">全业务流程系统处理成功率</label>' +
      '<div slider slider-include="summary-total-sys-success-rate"></div>' +
      '</div>'
    }
  }

  function summaryTotalSysSuccessRate(summaryTotalSysSuccessRateService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.scolor = '#2196F3';
        scope.successRate = summaryTotalSysSuccessRateService;
        scope.sys = attrs.summaryTotalSysSuccessRate;
        summaryTotalSysSuccessRateService.queryBySys(scope.sys);
      }
    };
  }

  summaryTotalSysSuccessRate.$inject = ['summaryTotalSysSuccessRateService'];

  function summaryTotalBusSuccessRateLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-total-bus-success-rate-layout">' +
      '<label class="title title-color2">全业务流程业务处理成功率</label>' +
      '<div slider slider-include="summary-total-bus-success-rate"></div>' +
      '</div>'
    }
  }

  function summaryTotalBusSuccessRate(summaryTotalBusSuccessRateService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.scolor = '#2196F3';
        scope.successRate = summaryTotalBusSuccessRateService;
        scope.sys = attrs.summaryTotalBusSuccessRate;
        summaryTotalBusSuccessRateService.queryBySys(scope.sys);
      }
    };
  }

  summaryTotalBusSuccessRate.$inject = ['summaryTotalBusSuccessRateService'];

  function summaryProvinceSysSuccessRateLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-province-sys-success-rate-layout">' +
      '<label class="title title-color2">省侧系统处理成功率</label>' +
      '<div slider slider-include="summary-province-sys-success-rate"></div>' +
      '</div>'
    }
  }

  function summaryProvinceSysSuccessRate(summaryProvinceSysSuccessRateService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.scolor = '#2196F3';
        scope.successRate = summaryProvinceSysSuccessRateService;
        scope.sys = attrs.summaryProvinceSysSuccessRate;
        summaryProvinceSysSuccessRateService.queryBySys(scope.sys);
      }
    };
  }

  summaryProvinceSysSuccessRate.$inject = ['summaryProvinceSysSuccessRateService'];

  function summaryProvinceBusSuccessRateLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-province-bus-success-rate-layout">' +
      '<label class="title title-color2">省侧业务处理成功率</label>' +
      '<div slider slider-include="summary-province-bus-success-rate"></div>' +
      '</div>'
    }
  }

  function summaryProvinceBusSuccessRate(summaryProvinceBusSuccessRateService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.scolor = '#2196F3';
        scope.successRate = summaryProvinceBusSuccessRateService;
        scope.sys = attrs.summaryProvinceBusSuccessRate;
        summaryProvinceBusSuccessRateService.queryBySys(scope.sys);
      }
    };
  }

  summaryProvinceBusSuccessRate.$inject = ['summaryProvinceBusSuccessRateService'];
})();